1. Field of the Invention
Methods and apparatuses consistent with the present invention relate to encoding and decoding an image, and more particularly, to encoding and decoding an image by more efficiently compressing encoding information of sub-blocks included in a current block.
2. Description of the Related Art
In image compression methods such as Moving Picture Experts Group-1 (MPEG-1), MPEG-2, MPEG-4, and H.264/MPEG-4 Advanced Video Coding (AVC), a picture is divided into macroblocks so as to encode an image. An optimum encoding mode is selected in consideration of a data size and a data distortion with respect to the macroblocks, and the macroblocks are encoded with the selected optimum encoding mode.
In order to encode macroblocks of a current picture, intra-prediction from among encoding methods does not use a reference picture but uses pixel values which are spatially adjacent to a current block to be encoded. First, a prediction block with respect to the current block is generated by using the adjacent pixel values. Then, the prediction block is subtracted from the current block so that a residual block is generated therefrom, and the generated residual block is encoded. According to the H.264 standard, one mode from among a total of 22 intra-prediction modes is used in order to predictably encode the current block.
FIG. 1 is a set of diagrams of a conventional 16×16 intra-prediction mode.
Referring to FIG. 1, there are a total of four conventional 16×16 intra-prediction modes, including a vertical mode, a horizontal mode, a direct current (DC) mode, and a plane mode.
FIG. 2 is a set of diagrams of a conventional 4×4 intra-prediction mode.
Referring to FIG. 2, there are a total of nine conventional 4×4 intra-prediction modes, including a vertical mode, a horizontal mode, a DC mode, a diagonal down-left mode, a diagonal down-right mode, a vertical-right mode, a horizontal down mode, a vertical-left mode, and a horizontal-up mode.
In addition to the 4×4 intra-prediction modes and the 16×16 intra-prediction modes, there is an 8×8 intra-prediction mode in which intra-prediction is performed in 8×8 block units.
Intra-prediction mode numbers, which are indexed in each of the nine 4×4 intra-prediction modes, are determined according to a frequency of use with respect to each of the nine modes. In terms of probability, the vertical mode, that is a #0 mode, is a most frequently used mode when the intra-prediction is performed with respect to a target block, and the horizontal-up mode, that is a #8 mode, is a least frequently used mode.
In order to decode a current block that has been predictably encoded by using intra-prediction, a receiver receiving data about the current block must have information about the intra-prediction mode of the current block. For this, when the intra-prediction encoding is performed, the information about the intra-prediction mode is inserted into a bitstream and transmitted to the receiver. Even when the information about the intra-prediction mode is inserted into the bitstream, prediction encoding is performed in order to reduce the number of bits. Hereinafter, a case in which an intra-prediction direction is encoded according to the H.264 standard will be described.
FIGS. 3A and 3B are diagrams for describing a conventional method of predictably encoding an intra-prediction mode. Here, a number of an intra-prediction mode of a current block 30 having a 4×4-size is referred to as P, a number of an intra-prediction mode of an upper adjacent block 31 is referred to as A, and a number of an intra-prediction mode of a left adjacent block 32 is referred to as L.
In image intra-prediction encoding according to the H.264 standard, information about the intra-prediction direction of the current block 30 is encoded by referring to the intra-prediction modes of the upper adjacent block 31 and the left adjacent block 32. The upper adjacent block 31 and the left adjacent block 32 are adjacent blocks in which encoding has been completed before the current block 30. The number of the intra-prediction modes of the upper adjacent block 31 and the left adjacent block 32, respectively, indicates the intra-prediction direction.
First, the number of the intra-prediction mode of the current block 30 is compared with a minimum value from among the number of the intra-prediction mode of the upper adjacent block 31 and the number of the intra-prediction mode of the left adjacent block 32. The minimum value from among the numbers is a prediction value for the number of the intra-prediction mode of the current block 30.
When the minimum value, that is, the prediction value is equal to the number of the intra-prediction mode of the current block 30, the intra-prediction mode is encoded with 1 and is inserted into a bitstream. A receiver receiving the bitstream refers to the number of the intra-prediction mode of the upper adjacent block 31 and the number of the intra-prediction mode of the left adjacent block 32, and determines the minimum value from among the numbers to be the number of the intra-prediction mode of the current block 30, thereby performing decoding according to the intra-prediction direction thereof. As described above, the intra-prediction mode numbers are determined according to the frequency of use with respect to each mode, and there is a high probability that the current block 30 may have a prediction direction similar to the upper and left adjacent blocks 31 and 32. Thus, there is a high probability that the minimum value from among the numbers of the intra-prediction modes of the upper and left adjacent blocks 31 and 32 is equal to the number of the intra-prediction mode of the current block 30. Therefore, there is also a high probability that information about the intra-prediction mode of the current block 30 may be indicated by using one bit, such that compression of the information is performed.
When the minimum value does not equal the number of the intra-prediction mode of the current block 30, 0 is inserted into the bitstream in order to indicate this inequality. Since the minimum value is not equal to the number of the intra-prediction mode of the current block 30, the number of the intra-prediction mode of the current block 30 cannot be determined via the upper and left adjacent blocks 31 and 32. Thus, information about the intra-prediction mode is inserted into the bitstream, in the form of ‘XXX’, that is, a size of three bits. Since there are nine intra-prediction modes, numbered from 0 to 8, and the minimum value is not the number of the intra-prediction mode of the current block 30, thus, eight numbers excluding the minimum value are indicated by using the three bits. To be more specific, when the number of the intra-prediction mode of the current block 30 is less than the minimum value from among the numbers of the intra-prediction modes of the upper and left adjacent blocks 31 and 32, a binary number representing the number of the intra-prediction mode of the current block 30 becomes a ‘XXX’ value. However, when the number of the intra-prediction mode of the current block 30 is greater than the minimum value, a value obtained by subtracting 1 from the binary number for the number of the intra-prediction mode of the current block 30 becomes the ‘XXX’ value.
According to the conventional methods, information about the intra-prediction direction of the current block 30 is compressed only when the minimum value from among the numbers of the intra-prediction modes of the upper and left adjacent blocks 31 and 32 is equal to the number of the intra-prediction mode of the current block 30. However, when the number of the intra-prediction mode of the current block 30 is not equal to the minimum value, the information about the intra-prediction direction is indicated by using a total of four bits.
For example, in the case where the current block 30 of FIG. 3A is assumed to use an intra-prediction mode of 1, the upper adjacent block 31 is assumed to use an intra-prediction mode of 0, and the left adjacent block 32 is assumed to use an intra-prediction mode of 2, since the minimum value of the numbers of the intra-prediction modes is 0, the minimum value is not equal to the number of the intra-prediction mode of the current block 30. Thus, the information about the intra-prediction direction has to be indicated by using four bits. In the case where all numbers of intra-prediction modes of all blocks having a 4×4-size included in a macroblock are not equal to a prediction value, a total of 64 bits are required to encode the intra-prediction modes. Thus, inefficiency is caused, since the number of bits necessary for encoding the information about the intra-prediction modes is increased, even though the prediction encoding has been performed.
Such inefficiency has been described with reference to intra-prediction, but inefficiency incurred by performing prediction encoding may be caused whenever different encoding information is predictably encoded. Thus, methods and apparatuses for encoding and decoding an image are required, wherein the methods and apparatuses can more efficiently encode the intra-prediction mode, that is, encoding information.